define(function() {
    return ['$scope','$location', '$interval','$timeout','$routeParams','bizProxy', function($scope,$location,$interval,$timeout,$routeParams,bizProxy) {
    	$scope.$emit("top-show",'true');//显示顶部
    	$scope.$emit('menuTypeLight','mine'); 	//控制底部menu高亮
    	$scope.$emit('bub-menu','true'); 	//隐藏底部menu
    	$scope.$emit('flag-tag','68'); 	//显示底部文字
    	
    	//默认值
    	$scope.isactive = false;
    	$scope.oldPassword = "";
    	$scope.newPassword = "";
    	
    	$scope.$watch('oldPassword', function() {
    		if(($scope.password).length > 0){
    			changeStyle();
    		}
		});
    	
    	$scope.$watch('newPassword', function() {
    		if(($scope.newPassword).length > 0){
    			changeStyle();
    		}
		});
    	
    	//点击确认
    	$scope.confirmPwd = function(){
    		if(($scope.newPassword).length < 6){
                $scope.$emit("promptAlertMsg","密码必须介于6-15个字符之间");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
				return;
    		}
    		changePwdByPwd();
    	}
    	
    	//设置登录密码
    	function changePwdByPwd(){
            var headerInfo = {},bizInfo = {};
            headerInfo.pageNum = '';
            headerInfo.pageSize = '';
            headerInfo.sessionId = transData.sessionId;
            
            bizInfo.setupType = "loginPwd"; //设置用户姓名
            bizInfo.oldPwd = $scope.oldPassword;
            bizInfo.newPwd = $scope.newPassword;
            $scope.$emit("loadingChange",true);
            bizProxy.queryProxyBizData("setupUserInfo", headerInfo,bizInfo,
                    function(tempData){
            			$scope.$emit("loadingChange",false);
                        if(tempData.isSuccess == "T"){
                            $scope.$emit("promptAlertMsg",'密码更改成功');
                            $scope.$emit("showCollect",true);
                            $timeout(function(){
                                $scope.$emit("showCollect",false);
                            },transData.promptTime);
            				$timeout(function(){
            					$location.path("/changePwdByOldPwd").replace();//想改变当前 URL 而不创建新的历史记录的话
            					$scope.$emit('goNext','/accountInfo');
            				},1500);
                        }
                    },
                    function(data){
                    	$scope.$emit("loadingChange",false);
                        $scope.$emit("promptAlertMsg",data.errorMsg);
                        $scope.$emit("showCollect",true);
                        $timeout(function(){
                            $scope.$emit("showCollect",false);
                        },transData.promptTime);
                    }
            );
        }
    	
    	//切换样式
    	function changeStyle(){
    		if(($scope.oldPassword).length > 0 && ($scope.newPassword).length > 0){
				$scope.isactive = true;
			}else{
				$scope.isactive = false;
			}
    	}
    	$scope.$apply();
    }];
});